package com.efounder.ui;

import android.content.Context;
import android.content.SharedPreferences;
import android.os.Bundle;
import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity;

import com.efounder.frame.language.MultiLanguageUtil;
import com.efounder.utils.JfResourceUtil;
import com.utilcode.util.StatusBarUtil;

import me.imid.swipebacklayout.lib.StatusBarFontUtil;
import me.imid.swipebacklayout.lib.app.SwipeBackActivityHelper;
import pub.devrel.easypermissions.EasyPermissions;

public class BaseActivity extends AppCompatActivity {
    private SwipeBackActivityHelper mHelper;

    @Override
    protected void attachBaseContext(Context newBase) {
        super.attachBaseContext(MultiLanguageUtil.setLocal(newBase));
    }
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
//        Sofia.with(this)
//                .statusBarDarkFont()sw
//              //  .statusBarBackground(ContextCompat.getColor(this, R.color.white))
//                .navigationBarBackground(ContextCompat.getColor(this, R.color.white));
//        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
//            Window window = this.getWindow();
//            window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
//            window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
//            window.setStatusBarColor(getResources().getColor(R.color.title_Background));
//        }

        setStatusBar();
        SharedPreferences mSharedPreferences = getSharedPreferences("mSharedPreferences", Context.MODE_PRIVATE);
        SharedPreferences.Editor edit = mSharedPreferences.edit();
        String statusDarkValue = mSharedPreferences.getString("statusDarkValue", "false");
        if (statusDarkValue.equals("true")) {
            StatusBarFontUtil.setStatusBarDarkFont(this, true);
        }
    }
    /**
     * 设置状态栏颜色
     */
    protected void setStatusBar() {
        StatusBarUtil.setColor(this, JfResourceUtil.getSkinColor(com.efounder.thirdpartycomps.R.color.title_Background),0);
    }

    @Override
    public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
        super.onRequestPermissionsResult(requestCode, permissions, grantResults);
        EasyPermissions.onRequestPermissionsResult(requestCode, permissions, grantResults, this);
    }

}
